<?php

namespace app\admin\model\ela;

use think\Model;

class Mainlist extends Model
{
    // 表名
    protected $name = 'ela_mainlist';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'kind_text',
        'stock_text',
        'status_text'
    ];
    

    
    public function getKindList()
    {
        return ['0' => __('Kind 0'),'1' => __('Kind 1'),'2' => __('Kind 2'),'3' => __('Kind 3'),'4' => __('Kind 4'),'5' => __('Kind 5'),'6' => __('Kind 6'),'7' => __('Kind 7')];
    }     

    public function getStockList()
    {
        return ['0' => __('Stock 0'),'1' => __('Stock 1'),'2' => __('Stock 2')];
    }     

    public function getStatusList()
    {
        return ['0' => __('Status 0'),'1' => __('Status 1'),'2' => __('Status 2'),'3' => __('Status 3')];
    }     


    public function getKindTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['kind']) ? $data['kind'] : '');
        $list = $this->getKindList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStockTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['stock']) ? $data['stock'] : '');
        $list = $this->getStockList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
